<?php
require_once 'AES128.php';
require_once 'AESKey.php';

/**
 * 暗号化
 * AES
 * @author    Soochow University
 * @version   1.0
 * @exclude   作  成  日：2011/04/07
 *
 */
class AES {
    /**
     * keystring
     */
    private $keystring;
    
    /**
     * aesobj
     */
    private $aesobj;
    
    /**
     * 初期化
     */
    public function __construct() {
        $key = new AESKey();
        $this->keystring = md5($key->getKey());
        $this->aesobj = new AES128();
    }

    /**
     * 暗号化
     * getEncryptString
     * @param $encryptString
     */
    public function getEncryptString($enstring) {
        if($enstring == "")
        return $enstring;
        
        $encryptString = $this->aesobj->encrypt($enstring, $this->keystring);
        return $encryptString;
    }

    /**
     * 暗号化された値を解読
     * getDecryptString
     * @param $destring
     */
    public function getDecryptString($destring) {
        if($destring == "")
        return $destring;
       
        $decryptString = $this->aesobj->decrypt($destring, $this->keystring);
        return $decryptString;
    }
}